package com.mine.juc;


/**
 * 并发抢票问题
 * @author wang
 */
public class ParallelProblem {
    private static int count = 10;

    public static class MyRunnable implements Runnable {

        @Override
        public void run() {
            while (true) {
                if (count <= 0) {
                    break;
                }
                System.out.println(Thread.currentThread().getName() + ", count是：" + count--);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        new Thread(new MyRunnable()).start();
        new Thread(new MyRunnable()).start();
        new Thread(new MyRunnable()).start();
        new Thread(new MyRunnable()).start();
        new Thread(new MyRunnable()).start();
        new Thread(new MyRunnable()).start();
    }
}
